/*****************************************************************************
 * plum_kal_api.h
 *
 * Copyright (C) 2020 Jeasonvor <1101627719@qq.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 ****************************************************************************/

#ifndef __PLUM_KAL_API_H__
#define __PLUM_KAL_API_H__

/*****************************************************************************
 * Included Files
 ****************************************************************************/

#if !defined(PLUM_API_INCLUDE)
#error "Only 'plum_api.h' can be include directly"
#endif

#include "kal/include/plum_kal_mem.h"

#include "kal/include/plum_kal_thread.h"
#include "kal/include/plum_kal_mutex.h"
#include "kal/include/plum_kal_sem.h"
#include "kal/include/plum_kal_mq.h"
#include "kal/include/plum_kal_timer.h"

#if defined(CONFIG_KAL_LINUX_ENABLE)
#include <pthread.h>
#include <mqueue.h>
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <signal.h>
#include <time.h>

#elif defined(CONFIG_KAL_FREERTOS_ENABLE)
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
#include "timers.h"
#include "semphr.h"
#include "heap_4.h"

#elif defined(CONFIG_KAL_RT_THREAD_ENABLE)
#include "rtthread.h"

#elif defined(CONFIG_KAL_HARMONYOS_ENABLE)
#include "hi_mem.h"
#include "hi_task.h"
#include "hi_msg.h"
#include "hi_mux.h"
#include "hi_timer.h"
#include "hi_sem.h"
#include "hi_config.h"

#elif defined(CONFIG_KAL_CMSISOS_ENABLE)
#include "cmsis_os.h"

#elif defined(CONFIG_KAL_CMSISOS2_ENABLE)
#include "cmsis_os2.h"

#else
warn "not config system kernel!!!"
#endif

#if defined(CONFIG_KAL_LINUX_ENABLE)
#define KAL_MQ_SIMULATION
#endif

/*****************************************************************************
 * Pre-processor Definitions
 ****************************************************************************/
#define PLUM_OS_KERNEL_INCLUDE
/*****************************************************************************
 * Public Types
 ****************************************************************************/

/*****************************************************************************
 * Public Data
 ****************************************************************************/

/****************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
/*****************************************************************************
 * Public Function Prototypes
 ****************************************************************************/

PLUM_INLINE
plum_s32 plum_kal_hdl_register(plum_void *data)
{
    return plum_handle_register(data);
}

PLUM_INLINE
plum_s32 plum_kal_hdl_delete(plum_u32 id)
{
    return plum_handle_delete(id);
}

PLUM_INLINE
plum_s32 plum_kal_hdl_modify(plum_u32 id, plum_void *data)
{
    return plum_handle_modify(id, data);
}

PLUM_INLINE
plum_void *plum_kal_hdl_find(plum_u32 id)
{
    return plum_handle_find(id);
}

/****************************************************************************/
#ifdef __cplusplus
}
#endif
/****************************************************************************/
#endif /* __PLUM_KAL_API_H__ */
/****************************************************************************/

/****************************************************************************/
/*                                                                          */
/*  End of file.                                                            */
/*                                                                          */
/****************************************************************************/
